import { DataTypes } from 'sequelize'
const seq = require('../db/seq')

const PermisModels: any = seq.define('permis', {
  id: {
    autoIncrement: true,
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true
  },
  name: {
    type: DataTypes.STRING(45),
    allowNull: false,
    comment: "权限名称"
  },
  permission: {
    type: DataTypes.STRING(255),
    allowNull: true,
    comment: "权限字符串"
  },
  resource_type: {
    type: DataTypes.STRING(45),
    allowNull: true,
    comment: "类型（菜单，按钮）"
  },
  parent_id: {
    type: DataTypes.INTEGER,
    allowNull: true,
    defaultValue: 0,
    comment: "父编号"
  },
  menu_id: {
    type: DataTypes.INTEGER,
    allowNull: true,
    defaultValue: 0,
    comment: "菜单级别0,1,2"
  },
  order: {
    type: DataTypes.INTEGER,
    allowNull: true,
    defaultValue: 0
  }
}, {
  tableName: 'permis',
  timestamps: false,
  indexes: [
    {
      name: "PRIMARY",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "id" },
      ]
    },
  ]
});

module.exports = PermisModels